package PhienBanIO;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;

public class DocGhiTheoDongCot {

    static int[][] A;
    static int m, n;
    public static void main(String[] args) {
        
        File fi = new File("D:\\a.txt");
        File fo = new File("D:\\out.txt");

        try {
            FileInputStream fin = new FileInputStream(fi);
            BufferedReader br = new BufferedReader( new InputStreamReader( fin ) );
            String s = new String();
            try {

                s = br.readLine().trim();
                m = new Integer(s); //rows
                s = br.readLine().trim();
                n = new Integer(s); //cols
                
                A = new int[m][n];
                for(int i = 0; i < m; i++)
                {
                    s = br.readLine().trim();
                    String[] B = s.split(" ");
                    for(int j = 0; j < n; j++)
                    {
                        A[i][j] = new Integer(B[j].trim());
                    }
                }                
                
            } 
            catch(NullPointerException e){
            	
            }
            FileOutputStream fout = new FileOutputStream(fo);
            PrintStream out = new PrintStream(fout);
            
            
            for(int i = 0; i < m; i++)
            {
                for(int j=0; j < n; j++)
                {
                    System.out.printf("%d ", A[i][j]);
                    out.print(A[i][j]+" ");
                }
                out.println();
                System.out.println();
            }
           
            
        } catch (FileNotFoundException ex) {
          
        	}
        
        catch (IOException ex) {
            
        }
    }
}
